package edu.scau.mis.person.service.impl;

import edu.scau.mis.person.domain.Employees;
import edu.scau.mis.person.mapper.EmployeesMapper;
import edu.scau.mis.person.service.IEmployeesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Employees)表服务实现类
 *
 * @author CJW
 * @since 2024-03-29 14:24:16
 */
@Service("employeesService")
public class EmployeesServiceImpl implements IEmployeesService {
    @Resource
    private EmployeesMapper employeesMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Employees selectById(Integer id) {
        return this.employeesMapper.selectById(id);
    }

    /**
     * 查询指定行
     *
     * @param employees 筛选条件
     * @return 查询结果
     */
    @Override
    public List<Employees> selectList(Employees employees) {
        return this.employeesMapper.selectList(employees);
    }

    /**
     * 新增数据
     *
     * @param employees 实例对象
     * @return 实例对象
     */
    @Override
    public Employees insert(Employees employees) {
        this.employeesMapper.insert(employees);
        return employees;
    }

    /**
     * 修改数据
     *
     * @param employees 实例对象
     * @return 实例对象
     */
    @Override
    public Employees update(Employees employees) {
        this.employeesMapper.update(employees);
        return this.selectById(employees.getId());
    }

    /**
     * 通过主键批量删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public int deleteByIds(Long[] id) {
        return employeesMapper.deleteByIds(id);
    }

}
